{extend name="../../admin/view/main"}

{block name="button"}
<button class='layui-btn layui-btn-sm layui-btn-primary' data-width="70%" data-open='{:url("add")}'>添加订单</button>
{/block}

{block name="content"}
<div class="layui-tab layui-tab-card">
	<ul class="layui-tab-title notselect">
		<!--{php}$types = ['ta' => '全部订单', 't1' => '信息待确认', 't2' => '信息有误', 't3' => '待认证', 't4' => '认证审核中', 't5' => '认证通过', 't6' => '认证失败', 't7' => '审批人审核', 't8' => '已完成'];{/php}-->
		{php}$types = ['ta' => '全部订单', 't1' => '信息待确认', 't2' => '信息有误', 'tb' => '待支付', 't3' => '待认证','t4' => '待视频取证', 't5' => '待审批人审核',
		't8' => '已完成'];{/php}
		{foreach $types as $k=>$v}{if isset($type) and 't'.$type eq $k}
		<li class="layui-this" data-open="{:url('index')}?type={$k}">{$v}<sup class="layui-badge border-radius">{$total[$k]??0}</sup>
		</li>
		{else}
		<li data-open="{:url('index')}?type={$k}">{$v}<sup class="layui-badge border-radius">{$total[$k]??0}</sup></li>
		{/if}{/foreach}
	</ul>
	{include file='shop/order/qr'}
	<div class="layui-tab-content">
		{include file='shop/order/index_search'}
		<table class="layui-table margin-top-10" lay-skin="line">
			{notempty name='list'}
			<thead>
			<tr>
				<th class='list-table-check-td think-checkbox'>
					<label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
				</th>
				<th>ID</th>
				<th>编号</th>
				<th>用户信息</th>
				<th>订单信息</th>
				<th></th>
			    <th>身份认证</th>
				<th>公证信息</th>
				<th>操作人</th>
				<th>操作</th>
			</tr>
			</thead>
			{/notempty}
			<tbody>
			{foreach $list as $key=>$vo}
			<tr>
				<td class='list-table-check-td think-checkbox'>
					<label><input class="list-check-box" type='checkbox' value='{$vo.id}'></label>
				</td>
				<td class="nowrap relative">
					<div>
						<div class="inline-block sub-strong-red">
							<div><span class="color-text">{$vo.id}</span></div>
						</div>
					</div>
				</td>
				<td class="nowrap relative">
					<div>
						<div class="inline-block sub-strong-red">
							{if $vo.base_type == 0}
							{if $vo.is_creater == 1}
							<div>主委托人<br><span class="color-text">{$vo.unified_numbering|default='-'}</span></div>
							{else}
							<div>副委托人<br><span class="color-text">{$vo.unified_numbering|default='-'}</span></div>
							{/if}
							{else}
							<span class="color-text">{$vo.order_no|default='-'}</span>
							{/if}
						</div>
					</div>
				</td>
				<td class="nowrap relative">
					<div>
						<div class="inline-block sub-strong-red">
							<div>委托人：<span class="color-text">{$vo.client_name|default='--'}</span></div>
							<div>联系电话：<span class="color-text">{$vo.client_phone|default='--'}</span></div>
						</div>
					</div>
				</td>
				<td class='nowrap'>
					<!--订单流程状态(0已取消,1信息确认中,2信息有误,3待认证,4认证审核中,5认证通过,6认证失败,7审批人审核,8已完成)-->
					{eq name='vo.status' value='0'}<span
						class="layui-badge layui-badge-middle layui-bg-gray layui-border-cyan"
						data-tips-text="{$vo.cancel_remark}">信息待提交</span>{/eq}
					{eq name='vo.status' value='1'}<span
						class="layui-badge layui-badge-middle layui-bg-orange">信息待确认</span>{/eq}
					{eq name='vo.status' value='2'}<span class="layui-badge layui-badge-middle layui-bg-red">信息有误</span>{/eq}
					{if $vo.status == 3 and $vo.payment_status == 0}<span
						class="layui-badge layui-badge-middle layui-bg-blue">待支付</span>{/if}
					{if $vo.status == 3 and $vo.payment_status == 1}<span
						class="layui-badge layui-badge-middle layui-bg-black">待认证</span>{/if}
					{eq name='vo.status' value='4'}<span
						class="layui-badge layui-badge-middle layui-bg-orange">待视频取证</span>{/eq}
					{eq name='vo.status' value='5'}<span
						class="layui-badge layui-badge-middle layui-bg-blue">待审批人审核</span>{/eq}
					{eq name='vo.status' value='6'}<span class="layui-badge layui-badge-middle layui-bg-red">认证失败</span>{/eq}
					{eq name='vo.status' value='7'}<span
						class="layui-badge layui-badge-middle layui-bg-black">审批人审核中</span>{/eq}
					{eq name='vo.status' value='8'}<span
						class="layui-badge layui-badge-middle layui-bg-green">已完成</span>{/eq}
					<div class="inline-block text-middle">
						<div class="sub-strong-blue">
							订单单号：<b>{$vo.order_no|default=''}</b>
							{eq name='vo.status' value='1'}
							<span class="margin-left-5 layui-badge layui-bg-blue" data-width="60%">信息确认</span>
							{/eq}
							{if $vo.status==3 && $vo.payment_status==0}
							<a class="margin-left-5 layui-badge layui-bg-blue" data-width="60%">待支付</a>
							{/if}

							 <!--onclick=download_qr("https://wxaurl.cn/6Iyci6bHd0b",'{$vo.order_no}')-->
							{if $vo.status==4 && $vo.payment_status==1}
							<!--<a class="margin-left-5 layui-badge layui-bg-blue" data-width="60%"  data-modal="{:url('audit')}?order_no={$vo.order_no}&type=4&id={$vo.id}">认证审核</a>-->
							{/if}
							{if $vo.status==4}
							<span class="margin-left-5 layui-badge layui-bg-blue" data-width="60%">待视频取证</span>
							{/if}

							{if $vo.status==5}
							<span class="margin-left-5 layui-badge layui-bg-blue" data-width="60%">审批人审核</span>
							{/if}

							{eq name='vo.status' value='7'}
							<span class="margin-left-5 layui-badge layui-bg-blue" data-width="60%">审批人审核</span>
							{/eq}
						</div>
						<div class="sub-strong-blue">
							<!--base_type  委托类型(0委托公证,1出生公证,2亲属关系公证)-->
							<!--is_creater  发起人 0 不是 1 是(多人委托时才生效)-->
							<!--{if $vo.base_type == 0 and $vo.is_creater == 0}-->
							<!--{else}-->
							<!--可以修改金额-->
							<!--status  订单流程状态(0已取消,1信息确认中,2信息有误,3待认证,4待视频取证,5认证通过,6认证失败,7审批人审核,8已完成)-->
							<!--payment_status  实际支付状态(0未支付,1已支付)-->
							<!--{$vo.status}-->
							<!--{$vo.payment_status}-->
							{if $vo.status == 1 and $vo.payment_status == 0}
							订单金额：
							<label>
								{if $vo.system_user_id=='0'}
								{$vo.amount_real+0}
								{else}
								<input
										data-action-blur="{:url('update_amount_real')}"
										data-value="id#{$vo.id};amount_real#{value}" data-loading="false"
										value="{$vo.amount_real+0}" class="list-sort-input">
								{/if}

							</label> 元
							{else}
							订单金额：<b>{$vo.amount_real+0}</b> 元
							{/if}

							<!--{/if}-->
						</div>
						<div>下单时间：<span class="color-text">{$vo.create_at|format_datetime}</span></div>
						<!--{notempty name='vo.payment_status'}-->
						<div>
							支付时间：<span class="color-text">{$vo.payment_datetime|format_datetime}</span>
							{notempty name='vo.payment_name'}
							<!--{notempty name='vo.payment_image'}-->
							<b class="margin-left-5 color-blue" data-tips-image="{$vo.payment_image}"
							   data-tips-text="{$vo.payment_remark|default=''}">({$vo.payment_name|default='-'})</b>
							<!--{else}-->
							<b class="margin-left-5 color-blue">({$vo.payment_name|default='-'})</b>
							<!--{/notempty}-->
							{/notempty}
						</div>
						<!--{else}-->
						支付状态：<span class="color-desc">未支付</span>
						<!--{/notempty}-->
					</div>
				</td>
				<td class='nowrap'>
					<!--订单流程状态(0已取消,1信息确认中,2信息有误,3待认证,4认证审核中,5认证通过,6认证失败,7审批人审核,8已完成)-->
					<div class="inline-block text-middle">
						<div class="sub-strong-blue">
							{if $vo.status==3 && $vo.payment_status==0}
							<!--onclick=download_qr("https://wxaurl.cn/6Iyci6bHd0b",'{$vo.order_no}')-->
							<a class="margin-left-5 layui-badge layui-bg-blue" data-width="60%" onclick="getQrcode('{$vo.id}')">二维码</a>
							{/if}
							{if $vo.status == 3 and $vo.payment_status == 1}
							<a class="margin-left-5 layui-badge layui-bg-blue" data-width="60%" onclick="getQrcode('{$vo.id}')">二维码</a>
							{/if}
							{eq name='vo.status' value='4'}
							<a class="margin-left-5 layui-badge layui-bg-blue" data-width="60%" onclick="getQrcode('{$vo.id}')">二维码</a>
							{/eq}
						</div>
					</div>
				</td>
				<td class='nowrap'>
					{if $vo.status==4 || $vo.status==5 || $vo.status==8}
							已认证
					{else}
							未认证
					{/if}

				</td>
				<td class="nowrap">
					<div>
						<div class="inline-block sub-strong-red">
							<div>公证处：<span class="color-text">{$vo.notarial_office_name|default='--'}</span></div>
							<div>业务类型：<span class="color-text">{$vo.type_text|default='--'}-{$vo.matter_name|default='--'}</span>
							</div>
							<div>证书份数：<span class="color-text">{$vo.number_goods|default='--'} 份</span></div>
						</div>
					</div>
				</td>
				<td class="nowrap">
					<div class="inline-block sub-strong-red">
						<div>公证员：<span class="color-text">{$vo.sys_name|default='--'}</span></div>
						<div>审批人：<span class="color-text">{$vo.approval_name|default='--'}</span></div>
					</div>
				</td>
				<td class="nowrap">
					<!--未受理-->
					{if $vo.system_user_id == '0'}
					<a class="layui-btn layui-btn-sm" data-title="查看订单信息" data-width="60%"
					   data-modal='{:url("details")}?id={$vo.id}'>查 看</a>
					<a class="layui-btn layui-btn-sm layui-bg-blue" data-width="60%" data-action="{:url('accept')}"
					   data-value="id#{$vo.id};status#1">受理</a>
					<!--已受理-->
					{else}
					<!--信息待确认-->
					{eq name='vo.status' value='1'}
					<a class="layui-btn layui-btn-sm layui-btn-warm" data-width="60%" data-action="{:url('accept')}"
					   data-value="id#{$vo.id};status#0">退回</a>
					<a class="layui-btn layui-btn-sm layui-bg-blue" data-width="60%"
					   data-modal="{:url('audit')}?order_no={$vo.order_no}&type=1&id={$vo.id}">编辑</a>
					<a class="layui-btn layui-btn-sm layui-bg-blue" data-width="60%" data-confirm="确定已经编辑完成吗？"
					   data-action="{:url('status')}" data-value="id#{$vo.id};status#3">确认</a>
					<a class="layui-btn layui-btn-sm layui-bg-blue" data-width="60%" data-confirm="确定要驳回吗？"
					   data-action="{:url('status')}" data-value="id#{$vo.id};status#2">驳回</a>
					{/eq}

					{if $vo.status==4 && $vo.payment_status==1}
					<!--<a class="margin-left-5 layui-badge layui-bg-blue" data-width="60%"  data-modal="{:url('audit')}?order_no={$vo.order_no}&type=4&id={$vo.id}">认证审核</a>-->
					{/if}
					{if $vo.status==4}
					<a class="layui-btn layui-btn-sm layui-bg-blue" data-width="60%" data-action="{:url('status')}"
					   data-value="id#{$vo.id};status#5">视频取证完成</a>
					{/if}

					<!--待审批-->
					{if $vo.status==5}
					{if $vo.approval_user_id == 0}
					<a class="layui-btn layui-btn-sm layui-bg-blue" data-width="30%" data-height="500px"
					   data-modal="{:url('approval_user')}?id={$vo.id}">提交</a>
					<a class="layui-btn layui-btn-sm layui-bg-blue" data-width="60%" data-action="{:url('status')}"
					   data-value="id#{$vo.id};status#2">驳回</a>
					{elseif $vo.approval_user_id==$user_id}
					<a class="layui-btn layui-btn-sm layui-bg-blue" data-width="60%" data-confirm="确定要审核通过吗？"
					   data-action="{:url('status')}" data-value="id#{$vo.id};status#8">确认</a>
					<a class="layui-btn layui-btn-sm layui-bg-blue" data-width="60%" data-confirm="确定要审核驳回吗？"
					   data-action="{:url('approval_order')}" data-value="id#{$vo.id};">驳回</a>
					<!--<a class="layui-btn layui-btn-sm layui-bg-blue" data-width="30%" data-height="500px"-->
					   <!--data-modal="{:url('approval_user')}?id={$vo.id}">视频内容</a>-->
					{/if}


					{/if}

					{eq name='vo.status' value='7'}
					<a class="layui-btn layui-btn-sm layui-bg-blue" data-width="60%"
					   data-modal="{:url('audit')}?order_no={$vo.order_no}&type=7&id={$vo.id}">编辑</a>
					<a class="layui-btn layui-btn-sm layui-bg-blue" data-width="60%" data-confirm="确定要审核通过吗？"
					   data-action="{:url('status')}" data-value="id#{$vo.id};status#8">确认</a>
					<a class="layui-btn layui-btn-sm layui-bg-blue" data-width="60%" data-confirm="确定要审核驳回吗？"
					   data-action="{:url('status')}" data-value="id#{$vo.id};status#2">驳回</a>
					{/eq}
					<a class="layui-btn layui-btn-sm" data-title="查看订单信息" data-width="60%"
					   data-modal='{:url("details")}?id={$vo.id}'>查 看</a>
					{/if}
					{if auth("remove")}
					<a class="layui-btn layui-btn-sm layui-btn-xs layui-btn-danger" data-confirm="确定要删除该订单吗？"
					   data-action="{:url('remove')}" data-value="id#{$vo.id}">删 除</a>
					{/if}


				</td>
			</tr>
			{/foreach}
			</tbody>
		</table>
		{empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
	</div>
</div>
<script>
	function getQrcode(id)
	{
	    let postData = {'id': id};
        url = "{:url('getQrcode')}";
        $.post(url, postData, function (result) {
            if (result.code == '1'){
                let link = result.data
	            download_qr(link,id);
            }

        }, 'json')
	}
</script>
{/block}
